home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4810 / 4810.xpi / chrome / speeddial.jar / content / firstTimeConfig.js < prev    next >
Text File  |  2010-01-31  |  4KB  |  87 lines

  1. var gPref = Components.classes["@mozilla.org/preferences-service;1"]
  2.                .getService(Components.interfaces.nsIPrefService)
  3.                .QueryInterface(Components.interfaces.nsIPrefBranch2);
  4. var isFirefox3 = false;
  5.  
  6. function Startup() {
  7.   // Detect version
  8.   var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULAppInfo)
  9.   // only if this is Firefox
  10.   var versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
  11.                       .getService(Components.interfaces.nsIVersionComparator);
  12.   // only if the platform version is 1.9 or greater
  13.   if (versionChecker.compare(appInfo.platformVersion, "1.9a1") >= 0) {
  14.     isFirefox3 = true;
  15.   }
  16.  
  17.   // Set the initial data
  18.   document.getElementById("loadInNewWindow").checked = gPref.getBoolPref("extensions.speeddial.loadInNewWindow");
  19.   document.getElementById("loadInNewTab").checked = gPref.getBoolPref("extensions.speeddial.loadInNewTab");
  20.   document.getElementById("enableGroups").checked = gPref.getBoolPref("extensions.speeddial.enableGroups");
  21.   document.getElementById("thumbnailRendering").selectedIndex = 0;
  22.   
  23.   if (isFirefox3) {
  24.     document.getElementById("thumbnailRenderingBox").setAttribute("hidden", true);
  25.   } else {
  26.     var qualityRendering = gPref.getBoolPref("extensions.speeddial.oldResampling");
  27.     if (qualityRendering) {
  28.       document.getElementById("thumbnailRendering").selectedIndex = 1;
  29.     } else {
  30.       document.getElementById("thumbnailRendering").selectedIndex = 0;
  31.     }
  32.   }
  33. }
  34.  
  35. function onOK(event) {
  36.   // Set the changed data
  37.   gPref.setBoolPref("extensions.speeddial.loadInNewWindow", document.getElementById("loadInNewWindow").checked);
  38.   gPref.setBoolPref("extensions.speeddial.loadInNewTab", document.getElementById("loadInNewTab").checked);
  39.   gPref.setBoolPref("extensions.speeddial.enableGroups", document.getElementById("enableGroups").checked);
  40.     
  41.   if (document.getElementById("addToolbarIcon").checked) {
  42.     var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
  43.     var windowIter = wm.getEnumerator('navigator:browser');
  44.    
  45.     if (windowIter.hasMoreElements()) {
  46.       var targetWindow = windowIter.getNext();
  47.       if (targetWindow.wrappedJSObject) {
  48.         targetWindow = targetWindow.wrappedJSObject;
  49.       }
  50.       targetWindow.SpeedDial.addToolbarIcon();
  51.     }
  52.   }
  53.  
  54.   if (document.getElementById("setAsHomePage").checked) {
  55.     var aURL = "chrome://speeddial/content/speeddial.xul";
  56.     var str = Components.classes["@mozilla.org/supports-string;1"]
  57.                         .createInstance(Components.interfaces.nsISupportsString);
  58.     str.data = aURL;
  59.     gPref.setComplexValue("browser.startup.homepage",
  60.                                  Components.interfaces.nsISupportsString, str);
  61.     try {
  62.       var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
  63.       var windowIter = wm.getEnumerator('navigator:browser');
  64.      
  65.       if (windowIter.hasMoreElements()) {
  66.         var targetWindow = windowIter.getNext();
  67.         var homeButton = targetWindow.document.getElementById("home-button");
  68.         homeButton.setAttribute("tooltiptext", aURL);
  69.       }
  70.     } catch (ex) {}
  71.   }
  72.   
  73.   if (document.getElementById("addWeatherDial").checked) {
  74.     SpeedDialUtils.setupWeatherDial();
  75.   }
  76.   
  77.   if (!isFirefox3) {
  78.     var qualityRendering = (document.getElementById("thumbnailRendering").selectedIndex == 1);
  79.     gPref.setBoolPref("extensions.speeddial.oldResampling", qualityRendering);
  80.   }
  81.   
  82.   return true;
  83. }
  84.  
  85. function onCancel(event) {
  86.   return true;
  87. }